import { Context } from "koa";
import Game from "../game/Game";

export interface UserData{
    username:string;
    phone_number:number;
    password:string;
    userid:string;
    icon:string;
    sex:string;
    scoreNum:number;
}

//用户字典
export interface UserMap{
    [key:string]:Client
}


export interface Client{
    userid:string;
    ctx?:Context;
}
//房间属性
export class Room{
    public game:Game;
    public playerClients:Map<string,Client>
    constructor(public adminname:string,public adminid:string,public roomid:string,public roomname:string,public usercount:number,public create_time:number){
        this.game = new Game(this);
        this.playerClients = new Map();
    }
}

//扑克牌属性
export interface Card{
    type:string;
    value:number;
}

//广播类型
export interface SocketResponse{
    cmd:'SendCard'|//发牌
        'join'|//玩家加入
        'ext'|//玩家退出
        'go'|//玩家出牌
        'landlordplayer'|//选择叫地主的玩家
        'playerToScore'|//玩家叫分
        'reset'|//重置游戏
        'playerReady'|//玩家准备
        'game-over'|//游戏结束
        'landlord';//地主玩家
    message?:string;
    players?:string[];
    userid:string;
    data?:{ [key:string]:any };
}

export interface SocketRequest{
    cmd:'go'|'playerToScore'|'ready'|'join';
    userid:string;
    data:{[key:string]:any}
}